/**
 * 
 */
// 功能键无效化
document.oncontextmenu = function(e) {  
	//return false;  
};  
document.onkeydown=function(){
	var srcElement = (document.all) ? event.srcElement : event.target;
	if ( event.keyCode==116){
		event.keyCode = 0;
		event.cancelBubble = true;
		return false;
	}	
	// Backspace
    if(srcElement.type != "textarea" && srcElement.type != "text" && srcElement.type != "password") {
        if (event.keyCode == 8) {
        	//return false;
    	}    	
    }
    if(event.altKey){
	    return false;
	}
    if(event.ctrlKey){
	    return false;
	}
    if(event.shiftKey){
	    //return false;
	}
};
function getOs(){  
    var OsObject = "";  
   if(navigator.userAgent.indexOf("MSIE")>0) {  
        return "MSIE";  
   }  
   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){  
        return "Firefox";  
   }  
   if(isSafari=navigator.userAgent.indexOf("Safari")>0) {  
        return "Safari";  
   }   
   if(isCamino=navigator.userAgent.indexOf("Camino")>0){  
        return "Camino";  
   }  
   if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){  
        return "Gecko";  
   }      
}
function fn_change_backcolor(){//火狐下暂不能用
    document.execCommand('BackColor',true,'#ffff00');//true或false都可以
}
function qx_change_backcolor(){
    document.execCommand('BackColor',true,'#ddebf6');//true或false都可以
}

function strContains(str, sub){  
	if(str==null){
		return false;
	}
    return (str.indexOf(sub) != -1);  
}
///////////////////////////////////////////Map 类\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
function Map() {

this.elements = new Array();

this.size = function() {
return this.elements.length;
}

this.isEmpty = function() {
return (this.elements.length < 1);
}

this.clear = function() {
this.elements = new Array();
}

this.put = function(_key, _value) {
this.elements.push({key:_key, value:_value});
}

this.remove = function(_key) {
var bln = false;

try {
for (i = 0; i < this.elements.length; i++) {
if (this.elements[i].key == _key) {
this.elements.splice(i, 1);
return true;
}
}
} catch(e) {
bln = false;
}
return bln;
}

this.get = function(_key) {
try{
for (i = 0; i < this.elements.length; i++) {
if (this.elements[i].key == _key) {
return this.elements[i].value;
}
}
}catch(e) {
return null;
}
}

this.element = function(_index) {
if (_index < 0 || _index >= this.elements.length) {
return null;
}
return this.elements[_index];
}

this.containsKey = function(_key) {
var bln = false;
try {
for (i = 0; i < this.elements.length; i++) {
if (this.elements[i].key == _key) {
bln = true;
}
}
}catch(e) {
bln = false;
}
return bln;
}

this.containsValue = function(_value) {
var bln = false;
try {
for (i = 0; i < this.elements.length; i++) {
if (this.elements[i].value == _value){
bln = true;
}
}
} catch(e) {
bln = false;
}
return bln;
}

this.values = function() {
var arr = new Array();
for (i = 0; i < this.elements.length; i++) {
arr.push(this.elements[i].value);
}
return arr;
}

this.keys = function() {
var arr = new Array();
for (i = 0; i < this.elements.length; i++) {
arr.push(this.elements[i].key);
}
return arr;
}
}
/////////////////////////////////////////////////////////////////
function getGsHelp(){
  var dw=new DivWindow('popup','popup_drag','popup_exit','exitButton','250','683',4);

}
var DivWindow= function(popup/*最外层div id*/,popup_drag/*拖动div id*/,popup_exit/*退出按钮id*/ ,exitButton/*触发服务器端退出按钮id*/,varwidth,varheight,zindex){
  this.popup =popup ; //窗口名称
  this.popup_drag=popup_drag;
  this.height =varheight ; //窗口高度，并没用来设置窗口高度宽度，用来定位在屏幕的位置
  this.width =varwidth ; //窗口宽度
  this.popup_exit=popup_exit;
  this.exitButton=exitButton;
  this.zindex=zindex;      
  this.init = function(){ //初始化窗口
	this.popupShow();
	this.startDrag(); //设置拖动
	this.setCommond(); //设置关闭
	//DivWindow.ArrayW.push(document.getElementById(this.popup)); //存储窗口到数组
  };this.init();
};

//存储窗口到数组
DivWindow.ArrayW = new Array();

//字符串连接类
DivWindow.StringBuild = function(){
  this.arr = new Array();
  this.push = function(str){
	this.arr.push(str);
  };
  this.toString = function(){
	return this.arr.join("");
  };
};

//拖动类
DivWindow.Drag = function(o ,oRoot){
  var _self = this;
  //拖动对象
  this.obj = (typeof oRoot != "undefined") ?oRoot : o;
  this.relLeft = 0; //记录横坐标
  this.relTop = 0; //记录纵坐标
  o.onselectstart = function(){
	return false;
  };
  o.onmousedown = function(e){ //鼠标按下
	e = _self.fixE(e);
	_self.relLeft = e.clientX - _self.fixU(_self.obj.style.left); 
	_self.relTop = e.clientY - _self.fixU(_self.obj.style.top); 
	document.onmousemove = function(e){
	_self.drag(e);
	//_self.obj.style.border = "1px dashed #000000";
	//_self.obj.style.filter = "alpha(opacity=30)";
	//_self.obj.style.opacity = "0.3";
  };
  document.onmouseup  = function(){
	_self.end();
	//_self.obj.style.border = "1px solid #cccccc";
	//_self.obj.style.borderBottom = "2px solid #E0E0E0";
	//_self.obj.style.borderRight = "2px solid #E0E0E0";
	//_self.obj.style.filter = "alpha(opacity=100)";
	//_self.obj.style.opacity = "1";
  };
  };
  this.drag = function(e){ //拖动
  e = this.fixE(e);
  var l = e.clientX - this.relLeft;
  var t = e.clientY - this.relTop;
  if (t < 0){
	t = 0; //防止头部消失
  }
  this.obj.style.left = l +"px";
  this.obj.style.top = t +"px"; 
  };
  this.end = function(){ //结束拖动
  document.onmousemove = null;
  document.onmouseup = null;
  };
  this.fixE = function(e){ //修复事件
  if (typeof e == "undefined") e = window.event;
  return e;
  };
  this.fixU = function(u){ //处理px单位
  return parseInt(u.split("p")[0]);
  };
};

//窗口拖动
DivWindow.prototype.startDrag = function(){
  var obj = document.getElementById(this.popup);
  var drag = document.getElementById(this.popup_drag);   
  new DivWindow.Drag(drag,obj);
};


//设定窗口优先级
DivWindow.prototype.setTop = function(){
  document.getElementById(this.popup).onclick = 
  document.getElementById(this.popup).onmousedown = 
  function(){
	 for(var i=0;i<DivWindow.ArrayW.length;i++) {
	   DivWindow.ArrayW[i].style.zIndex = 1;
	 }
	 this.style.zIndex = 100;
  }; 
};
//显示
DivWindow.prototype.popupShow=function() {       
  //document.getElementById('mask').style.display="block";   
  //document.getElementById('mask').style.width=window.screen.width +20;
  //document.getElementById('mask').style.height=window.screen.width +20;
  var  element = document.getElementById(this.popup); 
  element.style.position   = "absolute"; 
  element.style.visibility = "visible"; 
  element.style.display    = "block"; 
  element.style.width=this.width;
  element.style.height='auto';
  element.style.left = (window.screen.width - this.width)/2+"px";
  //element.style.top  =(window.screen.height-this.height-100)/2+"px";
  element.style.top  =20+"px";
  element.style.zIndex=this.zindex;
} 
//设置关闭
DivWindow.prototype.setCommond = function(){
 var _self = this;
 //根对象
 var obj = document.getElementById(this.popup);
 var exit = document.getElementById(this.popup_exit);
 var triggServerEvent=document.getElementById(this.exitButton);

 //设置关闭
  exit.onclick = function(){
  obj.style.display = "none";
  obj.style.visibility = 'hidden'; 
  $("#buttons input.clearDisplay").click(); 
  //document.all.mask.style.display='none'//关闭遮罩层
	 //triggServerEvent.click();//触发服务器端退出事件
 };
};